package com.lesso.lll.sunflower.infra.repository.impl;

import com.lesso..sunflower.domain.repository.EmployeeRepository;
import com.lesso.zqz.sunflower.infra.mapper.EmployeeMapper;
import com.lesso.zqz.sunflower.model.Employee;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;

/**
 * EmployeeRepositoryImpl
 *
 * @author lll
 * @since 2025-07-02
 */
@Repository
public class EmployeeRepositoryImpl implements EmployeeRepository {
    private final EmployeeMapper employeeMapper;

    public EmployeeRepositoryImpl(EmployeeMapper employeeMapper) {
        this.employeeMapper = employeeMapper;
    }

    @Override
    public Integer save(Employee employee) {
        employee.setCreateTime(LocalDateTime.now());
        employee.setUpdateTime(LocalDateTime.now());
        employee.setDelStatus(0);
        employeeMapper.insert(employee);
        return Math.toIntExact(employee.getId());
    }
}
